package com.prototype.demo04;

public class TheGreatestSage {
    private Monkey monkey = new Monkey();
    // 看俺老孙72变
    public void change(){
        Monkey cMonkey ;
        for (int i = 1; i <= 10; i++) {
            cMonkey = (Monkey) monkey.deepClone();
            System.out.println("Monkey King's birth date="+ monkey.getBirthday());
            System.out.println("Copy monkey's birth date="+ cMonkey.getBirthday());
            System.out.println("Monkey King birthday == Copy Monkey birthday?"+ (monkey.getBirthday() == cMonkey.getBirthday()));
            System.out.println("Monkey King == Copy Monkey? "+ (monkey == cMonkey));
            // 金箍棒相等,说明持有的同一根金箍棒,而不是两根.这就是浅层克隆.克隆的是引用对象的地址
            System.out.println("Monkey King's Staff == Copy Monkey's Staff? "+ (monkey.getStaff() == cMonkey.getStaff()));
            System.out.println("<<======================裂变第 "+ i +" 个猴孙");
        }
    }
}
